import Taro from "@tarojs/taro";

let host = "https://manbingtest.cwade.cn";
const accountInfo = Taro.getAccountInfoSync();

// 正式版
if (accountInfo.miniProgram.envVersion === "release") {
  host = "https://manbing.cwade.cn";
}

export const baseUrl = `${host}/wenduo/api/v1/wechat`;

// 获取健康问卷
export const healthy = `${baseUrl}/health/homePage`;
// 提交问卷答案进行报告生成
export const generateReport = `${baseUrl}/health/pageResult`;
// 根据问卷获取某个报告
export const getReportByQuestionnaireUrlBuilder = (pageId: number) =>
  `${baseUrl}/health/${pageId}/report`;
export const getReportListUrl = `${baseUrl}/my/healthReports`;
// 登录
export const auth = `${baseUrl}/auth`;
// 获取用户积分
export const getUserScore = `${baseUrl}/userScore`;
// 获取用户手机
export const getPhone = `${baseUrl}/phone`;
export const getEncryptedData = `${baseUrl}/data`;
// 获取用户的健康数据和积分
export const todayProfile = `${baseUrl}/customer/today/profile`;
export const updateProfile = `${baseUrl}/customer/profile`;
// 获取用户健康历史数据
export const historyHealthData = `${baseUrl}/customer/history/profile`;
// 更新用户信息
export const updateUserInfo = `${baseUrl}/customer`;
// 获取用户信息
export const getCustomerInfo = `${baseUrl}/customer`;

// 商城产品列表及详情查询
export const getProductsUrl = `${baseUrl}/products`;
export const getProductDetailsUrl = (productId: string | number) =>
  `${baseUrl}/products/${productId}`;
export const getProductCategoriesUrl = `${baseUrl}/product-categorys`;
export const getSalesBannersUrl = `${baseUrl}/mall`;
export const getProductRecommendUrl = `${baseUrl}/products/recommend`;
export const pointsRedeemUrl = `${baseUrl}/order/points-redeem`;
export const confirmOrderUrl = `${baseUrl}/order`;
export const payUrl = orderId => `${baseUrl}/order/${orderId}/prepay`;

// 订单
export const getOrderList = `${baseUrl}/order`;

// 获取任务详情
export const getTaskDetail = `${baseUrl}/task`;
// 获取全部任务列表
export const getAllTaskList = `${baseUrl}/task/all`;
// 更新打卡任务
export const updateTaskRecord = `${baseUrl}/task/clock-in/task-record`;
// 获取当日用户任务列表
export const getTodayTaskList = `${baseUrl}/task/record/today/all`;
// 添加打卡任务
export const addTaskRecord = `${baseUrl}/task/task-record`;

// 获取测验题目每日2题
export const getTodayTests = `${baseUrl}/health-test/todayTests`;
// 提交测验结果
export const submitTest = `${baseUrl}/health-test/submit`;
// 查看是否有完成当日测验
export const completedTodayTests = `${baseUrl}/health-test/isCompletedToday`;
// 查看是否有完成所有测验
export const allCompletedTests = `${baseUrl}/health-test/isAllCompleted`;
